package com.bingo.datasecurity.controller;

import com.bingo.datasecurity.entity.po.AccountPo;
import com.bingo.datasecurity.service.AccountService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author bingo
 * @date 2024/2/6 11:37
 */
@RestController
@RequestMapping("account")
public class AccountController {


    @Resource
    private AccountService accountService;


    /**
     * 添加一个账号
     *
     * @param accountPo
     */
    @PostMapping("/addAccount")
    public String addAccount(AccountPo accountPo) {
        accountService.addAccount(accountPo);
        return "ok";
    }

    /**
     * 查询所有账号
     *
     * @return
     */
    @PostMapping("/queryAllAccount")
    public List<AccountPo> queryAllAccount() {
        return accountService.queryAllAccount();
    }


    /**
     * 通过账号名更新密码
     *
     * @param account
     * @param password
     */
    @PostMapping("/updatePasswordByAccount")
    public String updatePasswordByAccount(String account, String password) {
        accountService.updatePasswordByAccount(account, password);
        return "ok";
    }
}
